package com.fy.utils.excel.convert;


import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;

public class StatusConverter implements Converter<Integer> {
    //0-保存草稿箱，1-待审核，2-已通过，3-未通过
    private static final int AUDIT = 1;
    private static final int PASS = 2;
    private static final int FAIL = 3;

    @Override
    public Class supportJavaTypeKey() {
        return Integer.class;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return CellDataTypeEnum.STRING;
    }

    @Override
    public Integer convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        return null;
    }

    @Override
    public CellData convertToExcelData(Integer integer, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        String status = "";
//        0-保存草稿箱，1-待审核，2-已通过，3-未通过
        switch (integer){
            case AUDIT:
                status = "待审核";
                break;
            case PASS:
                status = "已通过";
                break;
            case FAIL:
                status = "未通过";
                break;
            default:
                status = "保存草稿箱";
                ;
        }

        return new CellData(status);
    }
}
